#include "utype.h"
#include "includes.h"
#include "appTimer.h"

static INT32U  AppTimerBase = 0;
extern void RunLed(void);

INT32U  GetAppTime(void)
{
  return AppTimerBase;
}

void AppTimer(INT16U TickMs){
  AppTimerBase += TickMs;
}

INT16U SetTimer(INT16U TimeInterval) // Timer interval < 0x8000 ms
{
  return (AppTimerBase&0xffff)+TimeInterval;
}

INT16U ChkTimer(INT16U Timer)
{
  INT16U delt;
  delt = Timer - (AppTimerBase&0xffff);  
  if(delt>0x8000) return 0; //time out
  return delt; // time remain to time out
}

INT32U SetTimerLong(INT32U TimeInterval) // Timer interval < 0x80000000 ms
{
  return AppTimerBase+TimeInterval;
}

INT32U ChkTimerLong(INT32U Timer)
{
  INT32U delt;
  delt = Timer - AppTimerBase;
  if(delt>0x80000000) return 0; //time out
  return delt; // time remain to time out
}


